package com.hanamaki.homework;

import java.util.Arrays;
import java.util.Scanner;

public class Demo05 {
    static Scanner scanner;

    static {
        scanner = new Scanner(System.in);
    }

    public static void main(String[] args) {
        aOrb();
        maxMin();
        test1(5);
        printMon();
        test2();
    }


    //    要求用户输入两个数a、b，如果a能被b整除或a加b大于1000，则输出a，否则输出b
    public static void aOrb() {
        System.out.println("请输入a的值");
        int a = scanner.nextInt();
        System.out.println("请输入b的值");
        int b = scanner.nextInt();

        int result = ((a % b == 0) || (a + b > 1000)) ? a : b;
        System.out.println(result);
    }

    //    输入三个整数，输出最大数和最小数
    public static void maxMin() {
        System.out.println("请输入三个数字 ，输入一个之后依次按回车结束");
        int[] arr = new int[3];
        for (int i = 0; i < arr.length; i++) {
            arr[i] = scanner.nextInt();
        }
        Arrays.sort(arr);
        System.out.println("最大值：" + arr[arr.length - 1]);
        System.out.println("最小值：" + arr[0]);
    }

    public static void test1(int x) {

        if (x < 0) {
            System.out.println(2 * x + 5);
        } else if (x >= 0 && x < 10) {
            System.out.println(x * x - x + 3);
        } else if (x >= 10) {
            System.out.println(x * x * x - 7 * x);
        } else {
            System.out.println("无根");
        }
    }

    public static void printMon() {
        String[] mon = {"J", "F", "M3", "A", "M5", "J6", "J7", "A8", "S", "O", "N", "D"};
        System.out.println("请输入月份号");
        int code = scanner.nextInt();
        System.out.println("当前的月份" + code + "英文为：" + mon[code - 1]);
    }

    public static void test2() {
        System.out.println("请输入三个数字 ，输入一个之后依次按回车结束");
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int c = scanner.nextInt();

        if (a + b > c && a + c > b && b + c > a) {
            if (a == b && a == c && b == c) {
                System.out.println("能构成等边三角形");
            } else if (a == b || a == c || b == c) {
                System.out.println("能构成等腰三角形");
            } else {
                System.out.println("能构成普通三角形");
            }
        }

    }

}
